home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GNUGEM27 / VDIOUT.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  4KB  |  214 lines

  1. /*
  2.  *    Vdi output functions library interface
  3.  *
  4.  *        v_pline     polyline
  5.  *        v_pmarker    draw markers
  6.  *        v_gtext     draw text
  7.  *        v_fillarea    filled area
  8.  *        v_cellarray draw array of rectangles
  9.  *        v_contourfill    flood fill
  10.  *        vr_recfl    fill rect
  11.  *
  12.  *            ++jrb    bammi@cadence.com
  13.  *            modified: mj -- ntomczak@vm.ucs.ualberta.ca
  14.  */
  15. #include "common.h"
  16.  
  17.  
  18. #ifdef __DEF_ALL__
  19.  
  20. #define L_v_pline
  21. #define L_v_pmarke
  22. #define L_v_gtext
  23. #define L_v_fillar
  24. #define L_v_cellar
  25. #define L_v_contou
  26. #define L_vr_recfl
  27.  
  28. #endif /* __DEF_ALL__ */
  29.  
  30.  
  31. #ifdef L_v_pline
  32.  
  33. /* v_pline    polyline
  34.  *    returns void
  35.  */
  36. void v_pline(int handle, int count, int pxyarray[])
  37. {
  38. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  39.     _vdiparams[2] = (void *) &pxyarray[0];
  40. #else                    /* 32 bit ints - let's copy */
  41.     register short i;
  42.     register short *pts = &_ptsin[0];
  43.     register int   *pxy = &pxyarray[0];
  44.  
  45.     for(i = count; i != 0; i-- )
  46.     {
  47.         *pts++ = *pxy++;
  48.         *pts++ = *pxy++;
  49.     }
  50. #endif
  51.  
  52.     __vdi__(VDI_CONTRL_ENCODE(6, count, 0, 0), handle);
  53.  
  54. #ifdef __MSHORT__
  55.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  56. #endif
  57. }
  58. #endif /* L_v_pline */
  59.  
  60.  
  61. #ifdef L_v_pmarke
  62.  
  63. /* v_pmarker    draw markers
  64.  *    returns void
  65.  */
  66. void v_pmarker(int handle, int count, int pxyarray[])
  67. {
  68. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  69.     _vdiparams[2] = (void *) &pxyarray[0];
  70. #else                    /* 32 bit ints - let's copy */
  71.     register short i;
  72.     register short *pts = &_ptsin[0];
  73.     register int   *pxy = &pxyarray[0];
  74.  
  75.     for(i = count; i != 0; i-- )
  76.     {
  77.         *pts++ = *pxy++;
  78.         *pts++ = *pxy++;
  79.     }
  80. #endif
  81.  
  82.     __vdi__(VDI_CONTRL_ENCODE(7, count, 0, 0), handle);
  83.  
  84. #ifdef __MSHORT__
  85.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  86. #endif
  87. }
  88. #endif /* L_v_pmarke */
  89.  
  90.  
  91. #ifdef L_v_gtext
  92.  
  93. /* v_gtext    draw text    (extra super slow -- don't ask me why)
  94.  * returns void
  95.  */
  96. v_gtext(int handle, int x, int y, char *str)
  97. {
  98.     unsigned char    ch;
  99.     short *ptr = _intin;
  100.  
  101.     _ptsin[0] = x;
  102.     _ptsin[1] = y;
  103.     while ( ch    = (unsigned char) *str++)
  104.     *ptr++ = ch;
  105.  
  106.     __vdi__(VDI_CONTRL_ENCODE(8, 1, (int)(ptr - _intin), 0), handle);
  107. }
  108. #endif /* L_v_gtext */
  109.  
  110.  
  111. #ifdef L_v_fillar
  112.  
  113. /* v_fillarea    filled area
  114.  *    returns void
  115.  */
  116. void v_fillarea(int handle, int count, int pxyarray[])
  117. {
  118. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  119.     _vdiparams[2] = (void *) &pxyarray[0];
  120. #else                    /* 32 bit ints - let's copy */
  121.     register short i;
  122.     register short *pts = &_ptsin[0];
  123.     register int   *pxy = &pxyarray[0];
  124.  
  125.     for(i = count; i != 0; i-- )
  126.     {
  127.         *pts++ = *pxy++;
  128.         *pts++ = *pxy++;
  129.     }
  130. #endif
  131.  
  132.     __vdi__(VDI_CONTRL_ENCODE(9, count, 0, 0), handle);
  133.  
  134. #ifdef __MSHORT__
  135.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  136. #endif
  137. }
  138. #endif /* L_v_fillar */
  139.  
  140.  
  141. #ifdef L_v_cellar
  142.  
  143. /* v_cellarray    draw array of rectangles
  144.  * returns void
  145.  */
  146. void v_cellarray(int handle, int pxyarray[], int row_length,
  147.          int elements, int nrows, int write_mode, int colarray[])
  148. {
  149.     short *wptr, *end;
  150.  
  151.     wptr = _ptsin;
  152.     end  = wptr + 4;
  153.     do {
  154.     *wptr++ = *pxyarray++;
  155.     } while (wptr < end);
  156.     wptr = (short *)&_contrl[7];
  157.     *wptr++ = row_length;
  158.     *wptr++ = elements;
  159.     *wptr++ = nrows;
  160.     *wptr    = write_mode;
  161.  
  162.     wptr = _intin;
  163.     end = wptr + (short)nrows * (short)elements;
  164.     while (wptr < end)
  165.     *wptr++ = *colarray++;
  166.  
  167.     __vdi__(VDI_CONTRL_ENCODE(10, 2, (int)(wptr - _intin), 0), handle);
  168. }
  169. #endif /* L_v_cellar */
  170.  
  171.  
  172. #ifdef L_v_contou
  173.  
  174. /* v_contourfill flood fill from seed point to either dsp.edge or colr index
  175.  * returns void
  176.  */
  177. void v_contourfill(int handle, int x, int y, int index)
  178. {
  179.     _ptsin[0] = x;
  180.     _ptsin[1] = y;
  181.     _intin[0] = index;
  182.     __vdi__(VDI_CONTRL_ENCODE(103, 1, 1, 0), handle);
  183. }
  184. #endif /* L_v_contou */
  185.  
  186.  
  187. #ifdef L_vr_recfl
  188.  
  189. /* vr_recfl fill rect
  190.  * returns void
  191.  */
  192. void vr_recfl(int handle, int pxyarray[])
  193. {
  194. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  195.     _vdiparams[2] = (void *) &pxyarray[0];
  196. #else                    /* 32 bit ints - let's copy */
  197.     short *wptr = _ptsin;
  198.  
  199.     *wptr++ = *pxyarray++;
  200.     *wptr++ = *pxyarray++;
  201.     *wptr++ = *pxyarray++;
  202.     *wptr =   *pxyarray;
  203. #endif
  204.  
  205.     __vdi__(VDI_CONTRL_ENCODE(114, 2, 0, 0), handle);
  206.  
  207. #ifdef __MSHORT__
  208.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  209. #endif
  210. }
  211. #endif /* L_vr_recfl */
  212.  
  213. /* -eof- */
  214.